package crm.view.setting.listener;

import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

import crm.model.Setting;

public class BroadcastFocusListener implements FocusListener {
	JTextField breadcastField;
	JFrame gui;
	public BroadcastFocusListener(JTextField breadcastField, JFrame gui){
		this.breadcastField=breadcastField;
		this.gui=gui;
	}
	public void focusGained(FocusEvent arg0) {

	}

	@Override
	public void focusLost(FocusEvent arg0) {
		if (Setting.setBroadcastAddress(breadcastField.getText())){

		}else{
			breadcastField.setText(Setting.getBroadcastAddress());
			//TODO: Umlaute bei JOptionPanne!
			JOptionPane.showMessageDialog(gui,
					"Die Eingegebene Broadcast-Addresse ist nicht zugelassen\nBitte ueberpruefen sie Diese",
					"Falsche Bradcast-Addresse",
					JOptionPane.ERROR_MESSAGE);
		}

	}

}